﻿using Moq;
using SmarterCharger.App.Infrastructure.Interfaces;
using SmarterCharger.App.ViewModel;
using SmarterCharger.Library.Infrastructure.Interfaces;
using SmarterCharger.Library.Model;
using SmarterCharger.Library.Services.Interfaces;
using SmarterCharger.Library.Tests.Unit.Infrastructure;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace SmarterCharger.App.Tests.Unit.FirstTimeUserViewModelSpecifications
{
    public abstract class FirstTimeUserViewModelTestBase : TestBase
    {
        protected FirstTimeUserViewModel ViewModel { get; private set; }
        protected Mock<ISmartPlugLoader> SmartPlugLoader { get; private set; }
        protected Mock<INavigationService> NavigationService { get; private set; }
        protected Mock<IMessageBoxService> MessageBoxService { get; private set; }
        protected Mock<ISettingsService> SettingsService { get; private set; }

        protected override void Arrange()
        {
            var smartPlugs = new List<SmartPlug> { new SmartPlug { EnergyDeviceId = Guid.NewGuid(), Name = "dummy-name", SerialNumber = "dummy-serial" }};
            var smartPlugLoaderResult = Task.FromResult<LoadSmartPlugResult>(new LoadSmartPlugResult { IsCredentialsValid = true, SmartPlugs = smartPlugs } );

            SmartPlugLoader = new Mock<ISmartPlugLoader>();
            SmartPlugLoader.Setup(l => l.Load(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(smartPlugLoaderResult);

            NavigationService = new Mock<INavigationService>();
            MessageBoxService = new Mock<IMessageBoxService>();
            SettingsService = new Mock<ISettingsService>();

            ViewModel = new FirstTimeUserViewModel(SmartPlugLoader.Object, NavigationService.Object, MessageBoxService.Object, SettingsService.Object);
        }
    }
}
